<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>elookinto</groupId>
    <artifactId>osgi_rest_sample</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>bundle</packaging>

    <name>felix-osgi-rest4</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    </properties>

    <dependencies>
        
        
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <version>4.0.3</version>
            <scope>provided</scope>
        </dependency>
        <!--
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version></version>
            <scope>provided</scope>
        </dependency>
        -->
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <version>4.2.0</version>
            <scope>provided</scope>
        </dependency>
        
        
    
        
        
            
        
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.13</version>
        </dependency>
        
       
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.13</version>
           
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.13</version>
        
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
            <version>1.13</version>
           
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>1.13</version>
            
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.2</version>
            
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.2</version>
           
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-jaxrs</artifactId>
            <version>1.9.2</version>
           
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-xc</artifactId>
            <version>1.9.2</version>
           
        </dependency>

        <dependency>
            <groupId>org.codehaus.jettison</groupId>
            <artifactId>jettison</artifactId>
            <version>1.3</version>
           
        </dependency>

        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.http.jetty</artifactId>
            <version>2.2.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>servlet-api</artifactId>
                    <groupId>javax.servlet</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        
          
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.http.bundle</artifactId>
            <version>2.2.0</version>
        </dependency>
        
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.2.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Activator>com.elookinto.sample.Activator</Bundle-Activator>
                        <Embed-Dependency>org.slf4j</Embed-Dependency>
                        <Export-Package>com.elookinto.sample</Export-Package>
                        <Import-Package>
                            org.osgi.service.http,
                            com.sun.jersey.api.core,
                            com.sun.jersey.api.container.filter,
                            com.sun.jersey.spi.container.servlet,
                            com.sun.jersey.api.client,
                            com.sun.jersey.api.client.config,
                            com.sun.xml.internal.bind.v2;version="0.0",
                            com.sun.istack.internal;version="0.0",
                            com.sun.xml.internal.bind.v2.model.impl;version="0.0",          
                            javax.annotation,
                            org.codehaus.jackson,
                            org.codehaus.jackson.annotate,
                            org.codehaus.jackson.map,
                            org.codehaus.jackson.xc,
                            javax.servlet,
                            javax.servlet.http,
                            javax.ws.rs,
                            javax.ws.rs.core,
                            javax.ws.rs.ext,
                            javax.xml.bind.annotation,
                            javax.xml.bind,
                            javax.xml.parsers,
                            javax.xml.datatype,
                            javax.activation;version=0.0.0,
                            javax.xml.namespace,
                            javax.xml.bind.annotation.adapters,
                            javax.xml.bind.helpers,
                            javax.xml.stream,
                            javax.xml.transform.sax,
                            javax.xml.transform.dom,
                            javax.xml.transform.stream,
                            javax.naming,
                            org.osgi.framework,
                            org.xml.sax,javax.xml.transform,
                            org.xml.sax.helpers,
                            org.w3c.dom,
                            org.osgi.util.tracker,
                            oracle.jdbc.driver;resolution:=optional,
                            org.apache.felix.http.api,
                            org.apache.commons.lang;resolution:=optional,
                        </Import-Package>
                        <Implementation-Title>jersey-osgi-http-service-bundle</Implementation-Title>
                    </instructions>
                    <unpackBundle>true</unpackBundle>
                </configuration>
                <!--
                <configuration>
                    <instructions>
                        <Bundle-Activator>com.att.ss.ors.Activator</Bundle-Activator>
                    </instructions>
                </configuration>
                -->
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>build-for-felix</id>
            <dependencies>
                <dependency>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.main</artifactId>
                    <version>4.0.3</version>
                </dependency>
                <dependency>
                    <groupId>org.osgi</groupId>
                    <artifactId>org.osgi.compendium</artifactId>
                    <version>4.2.0</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>compile</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <pathconvert property="plugins.jars" pathsep="${path.separator}">
                                            <path refid="maven.runtime.classpath"/>
                                            <map from="${project.build.directory}${file.separator}classes" to=""/>
                                        </pathconvert>
                                        <pathconvert pathsep=" " property="bundles">
                                            <path path="${plugins.jars}"/>
                                            <mapper>
                                                <chainedmapper>
                                                    <flattenmapper/>
                                                    <globmapper from="*" to="file:modules/*" casesensitive="no"/>
                                                </chainedmapper>
                                            </mapper>
                                        </pathconvert>
                                        <propertyfile file="${project.build.directory}/config.properties">
                                            <entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar"/>
                                            <entry key="org.osgi.framework.bootdelegation" value="*"/>
                                        </propertyfile>
                                        <copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar"/>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>2.2</version>
                        <executions>
                            <execution>
                                <id>create-executable-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
                                    </descriptors>
                                    <finalName>${project.build.finalName}</finalName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>run-on-felix</id>
            <dependencies>
                <dependency>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.main</artifactId>
                    <version>4.0.3</version>
                </dependency>
               
                <dependency>
                    <groupId>org.osgi</groupId>
                    <artifactId>org.osgi.compendium</artifactId>
                    <version>4.3.1</version>
                </dependency>
               
            </dependencies>
            
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <phase> install </phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            
                            <target>
                                <echo>!!!!!---You may need to Install third party jars by going to 3plibs and execute installjars!!!!</echo>
                                <echo> "what" ${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path} </echo>
                                <property name="vm.args" value="-cp C:\temp\t.jar"/>
                                <pathconvert property="plugins.jars" pathsep="${path.separator}">
                                    <path refid="maven.runtime.classpath"/>
                                    <map from="${project.build.directory}${file.separator}classes" to=""/>
                                </pathconvert>
                                <makeurl property="urls" separator=" ">
                                    <path path="${plugins.jars}"/>
                                    <path location="${project.build.directory}/${project.build.finalName}.jar"/>
                                </makeurl>
                                <propertyfile file="${project.build.directory}/run.properties">
                                    <entry key="felix.auto.start" value="${urls}"/>
                                    <entry key="felix.auto.deploy.action" value="uninstall,install,update,start"/>
                                    <entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache"/>
                                    <entry key="org.osgi.framework.bootdelegation" value="*"/>
                                    <entry key="org.osgi.framework.system.packages" value="javax.servlet,javax.servlet.http,com.sun.istack.internal,com.sun.xml.internal.bind.v2,com.sun.xml.internal.bind.v2.model.impl,com.sun.org.apache.xpath.internal.jaxp,javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callback,javax.security.auth.kerberos,javax.security.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.smartcardio,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.transaction,javax.transaction.xa,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.namespace,javax.xml.parsers,javax.xml.soap,javax.xml.stream,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.portable,org.omg.CORBA.TypeCodePackage,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.omg.PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.PortableServer.portable,org.omg.PortableServer.ServantLocatorPackage,org.omg.SendingContext,org.omg.stub.java.rmi,org.omg.stub.javax.management.remote.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.w3c.dom.xpath,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers"/>
                                    <entry key="org.osgi.framework.system.packages.extra" value="org.osgi.framework;version=1.6"/>
                                    
                                </propertyfile>
                                <makeurl property="run.properties.url" file="${project.build.directory}/run.properties"/>
                              
                                <java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
                                    <sysproperty key="felix.config.properties" value="${run.properties.url}"/>
                                    <jvmarg line="${vm.args}"/>
                                </java>
                            </target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <repositories>
        
    </repositories>
</project>
